package com.bootdo.clouddo.service.douban.impl;

import com.bootdo.clouddo.dao.douban.DbBookReviewMapper;
import com.bootdo.clouddo.domain.douban.DbBookReview;
import com.bootdo.clouddo.service.douban.IDbBookReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DbBookReviewServiceImpl implements IDbBookReviewService {

    @Autowired
    private DbBookReviewMapper dao;

    @Override
    public DbBookReview findById(Long id) {
        return dao.selectByPrimaryKey(id);
    }

    @Override
    public int save(DbBookReview record) {
        if(findById(record.getId()) != null)
            return dao.updateByPrimaryKeySelective(record);
        else
            return dao.insertSelective(record);
    }

    @Override
    public List<DbBookReview> findBySubjectId(Long subjectId) {
        return dao.findBySubjectId(subjectId);
    }

    @Override
    public List<Long> findExistsReviewIds() {
        return dao.findExistsReviewIds();
    }
}
